<template>
    <button class="btn btn default"
            :class="{'btn-success': followed}"
            v-text="text"
            @click="follow"
    >
    </button>
</template>

<script>
    export default {
        props: ['question'],
        mounted() {
            // TODO
//            axios.post('/api/question/follower').then(res => {
//                console.log(res.data);
//            })
        },
        data() {
            return {
                followed: false
            }
        },
        computed: {
            text() {
                return this.followed ? '已关注' : '关注该问题'
            }
        },
        methods: {
            follow() {
                axios.get('/api/user', {question: this.question}).then(res => {
                    console.log(res.data);
                    this.followed = true;
                })
            }
        }
    }
</script>
